#!/bin/bash

# 定义项目名称和版本
PROJECT_NAME="tcp-game-server"
VERSION="1.0"
BUILD_DIR="build"
PACKAGE_NAME="${PROJECT_NAME}-${VERSION}.tar.gz"

# 编译项目
make || { echo "Compilation failed"; exit 1; }

# 创建打包目录
mkdir -p ${BUILD_DIR}/${PROJECT_NAME}

# 复制编译后的二进制文件和其他所需文件到打包目录
cp -r tcp-game-server ${BUILD_DIR}/${PROJECT_NAME}/
# 如果有其他需要包含的文件或目录，也复制到打包目录中
# cp -r data/ ${BUILD_DIR}/${PROJECT_NAME}/
# cp -r config/ ${BUILD_DIR}/${PROJECT_NAME}/

# 创建 tar.gz 包
tar -czvf ${PACKAGE_NAME} -C ${BUILD_DIR} ${PROJECT_NAME}

# 清理构建目录
rm -rf ${BUILD_DIR}

echo "Package created: ${PACKAGE_NAME}"
